package com.thrd.taiexhibition.utils;

import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.view.View;

import com.thrd.basicframework.utils.CommonDialog;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.activity.QRcodeActivity;
import com.thrd.taiexhibition.fresco.FrescoImage;
import com.thrd.taiexhibition.fresco.FrescoUtils;


/**
 * @author: ${唐杰}
 * @date: 2021/3/9
 */
public class DialogUtils {
    //private static CommonDialog dialog;

    public static CommonDialog showQRDialog(Context context,String path) {
        CommonDialog.Builder builder = new CommonDialog.Builder(context);
        CommonDialog dialog = builder
                .setView(R.layout.dialog_qr_code)
               // .setStyle(R.style.MyDialogStyle)
                .setCancelTouchout(true)
                .setHeightdp(300)
                .setWidthdp(300)
                .build();

        FrescoImage mFrescoImage =builder.findViewById(R.id.fi_image);
        FrescoUtils.getInstance().setPrefixProgressLoad(context,mFrescoImage,path);
        dialog.show();
        return dialog;
    }


    public static void showQRDialog(Activity context, View image, String path) {
        Intent intent = new Intent(context, QRcodeActivity.class);
        intent.putExtra("URL",path);
        if(image==null){
            context.startActivity(intent);
        }else{
            context.startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(context, image, "transitionImg").toBundle());
        }

    }



    private static void hide(CommonDialog dialog){
        //隐藏虚拟按键，并且全屏
        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
            View v = dialog.getWindow().getDecorView();
            v.setSystemUiVisibility(View.GONE);
        } else if (Build.VERSION.SDK_INT >= 19) {
//for new api versions.
            View decorView = dialog.getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            decorView.setSystemUiVisibility(uiOptions);
        }


    }




}
